<template>
  <view class="main-container">
    <!-- 考试操作面板 -->
    <view class="exam-panel">
      <!-- 左侧导航 -->
      <view class="left">
        <navigator class="nva-item" hover-class="none" v-for="(item, index) in leftNavs" :key="index" :url="item.path">
          <image :src="item.img" />
          <view>{{ item.name }}</view>
        </navigator>
      </view>
      <!-- 中间导航 -->
      <view class="middle">
        <!-- 顺序练习 -->
        <UfastConicMask class="shun-xu-lian-xi" :rate="answerRate" :config="{
          borderBackground: 'transparent',
          borderWidth: '4px',
          startColor: '#d7e6fa',
          endColor: '#3684e6',
          circleSize: '6px',
          circleColor: '#3684e6',
          showEyes: true,
          eyesSize: '4px',
          eyesColor: '#d7e6fa',
        }" @tap="toExercise">
          <view class="content">
            <view>顺序练习</view>
            <text class="num">{{ answerCount }}/{{ qbCount }}</text>
          </view>
        </UfastConicMask>

        <!-- 模拟考试 -->
        <UfastConicMask class="mo-ni-kao-shi" :rate="0.88" :config="{
          borderBackground: 'transparent',
          borderWidth: '4px',
          startColor: '#a5f4bb',
          endColor: '#0fd848',
          circleSize: '6px',
          circleColor: '#0fd848',
          showEyes: true,
          eyesSize: '4px',
          eyesColor: '#a5f4bb',
        }" @tap="toMockExam">
          <view class="content">
            <view>模拟考试</view>
            <view>
              <view><text class="num">33</text>分</view>
            </view>
          </view>
        </UfastConicMask>
      </view>
      <!-- 右侧导航 -->
      <view class="right">
        <navigator class="nva-item" hover-class="none"
          :url="`/pagesExercise/selectBase/selectBase?baseType=${props.baseType}`">
          <image src="@/static/images/exam/right_item1.png" />
          <view>精简{{ selectQbCount }}题</view>
        </navigator>
        <navigator class="nva-item" hover-class="none" v-for="(item, index) in rightNavs" :key="index" :url="item.path">
          <image :src="item.img" />
          <view>{{ item.name }}</view>
        </navigator>
      </view>
    </view>
    <!-- 底部导航 -->
    <view class="bottom-navs-panel">
      <navigator class="bottom-nav-item" hover-class="none" v-for="(item, index) in bootomNavs" :key="index"
        :url="item.path">
        <view class="bottom-nav-title">{{ item.name }}</view>
        <image class="bottom-nav-gif" :src="item.img" mode="widthFix" v-if="item.img.includes('gif')" />
        <image class="bottom-nav-img" :src="item.img" mode="widthFix" v-else />
      </navigator>
    </view>
  </view>
</template>

<script setup lang="ts">
  import { ref, computed } from 'vue'
  import UfastConicMask from '@/components/UfastConicMask/UfastConicMask.vue'
  import { useLearnBaseQbCount } from '@/composables/LearnBase'
  import { useQuestionAnswerCount } from '@/composables/Exercise'

  import { useMockExamOverView } from '@/composables/MockExam'
  // props
  const props = defineProps({
    // 题库类型
    baseType: {
      type: String,
      required: true,
    },
  })
  // 学习题库试题相关的数量
  const { qbCount, selectQbCount } = useLearnBaseQbCount(props.baseType)
  // 答题数量
  const answerCount = computed(() => useQuestionAnswerCount(props.baseType).count.value)
  // 答题进度
  const answerRate = computed(() => answerCount.value! / qbCount.value!)
  const mockExamOverView = useMockExamOverView(props.baseType)
  // 左侧链接列表
  const leftNavs = ref([
    {
      name: 'VIP课程',
      img: '/static/images/exam/left_item1.gif',
      path: `/pagesMember/center/center`,
    },
    {
      name: '专项练习',
      img: '/static/images/exam/left_item2.png',
      path: `/pagesExercise/specialExercise/specialExercise?baseType=${props.baseType}`,
    },
    {
      name: '考前密卷',
      img: '/static/images/exam/left_item3.png',
      path: `/pagesExam/preExamPaper/preExamPaper?baseType=${props.baseType}`,
    },
    {
      name: '成绩·排名',
      img: '/static/images/exam/left_item4.png',
      path: '/',
    },
  ])
  // 右侧链接列表
  const rightNavs = ref([
    {
      name: '图标速记',
      img: '/static/images/exam/right_item2.png',
      path: `/pagesSign/signs/signs?baseType=${props.baseType}`,
    },
    {
      name: '真实考场模拟',
      img: '/static/images/exam/right_item3.png',
      path: `/pagesExam/mockRealExam/mockRealExam?baseType=${props.baseType}`,
    },
    {
      name: '错题·收藏',
      img: '/static/images/exam/right_item4.png',
      path: `/pagesExercise/ecRecords/ecRecords?baseType=${props.baseType}`,
    },
  ])

  // 底部链接列表
  const bootomNavs = ref([

    {
      name: '速记卡片',
      img: '/static/images/exam/sjkp.png',
      path: `/pagesExercise/shorthandCard/shorthandCard?baseType=${props.baseType}`,
    },
    {
      name: '视频讲解',
      img: '/static/images/exam/spjj.gif',
      path: `/pagesSign/signs/signs?baseType=${props.baseType}`,
    },
    {
      name: '新规资料',
      img: '/static/images/exam/xgzl.png',
      path: `/pagesFile/newRegulationInfos/newRegulationInfos?baseType=${props.baseType}`,
    },
    {
      name: '新规习题',
      img: '/static/images/exam/xgxt.png',
      path: `/pagesSign/signs/signs?baseType=${props.baseType}`,
    },
  ])

  // 去顺序练习
  const toExercise = () => {
    uni.navigateTo({
      url: `/pagesExercise/sequenceExercise/sequenceExercise?baseType=${props.baseType}`,
    })
  }
  // 去模拟考试
  const toMockExam = () => {
    uni.navigateTo({
      url: `/pagesExam/mockExam/mockExam?baseType=${props.baseType}`,
    })
  }


</script>

<style lang="scss" scoped>

  .main-container {

    display: flex;
    flex-direction: column;

    /* 考试操作面板 */
    .exam-panel {
      display: flex;
      padding: 40rpx 20rpx;
      width: 100vw;
      height: 800rpx;
      background-color: #fff;

      /* 左右操作图标 */
      .left,
      .right {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: center;
        width: 28%;

        .nva-item {
          display: flex;
          flex-direction: column;
          align-items: center;
          font-size: 30rpx;
          color: #000;
          text-align: center;

          image {
            width: 70rpx;
            height: 70rpx;
            margin-bottom: 10rpx;
          }
        }
      }

      /* 中间操作 */
      .middle {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: center;

        /* 顺序练习 */
        .shun-xu-lian-xi {
          width: 224rpx;
          height: 224rpx;
          background-image: url('@/static/images/exam/middle_item_2.png');
          background-size: cover;
        }

        /* 模拟考试 */
        .mo-ni-kao-shi {
          width: 224rpx;
          height: 224rpx;
          background-image: url('@/static/images/exam/middle_item_1.png');
          background-size: cover;
        }

        /* 顺序练习和模拟考试环形进度条颜色 */
        .content {
          color: #fff;
          display: flex;
          flex-direction: column;
          justify-content: space-around;
          align-items: center;
          height: 40%;
          font-size: 32rpx;
          font-weight: bold;

          .num {
            display: inline-block;
            height: 32rpx;
            line-height: 32rpx;
            font-size: 27rpx;
            vertical-align: middle;
          }
        }
      }
    }

    // 底部导航
    .bottom-navs-panel {
      display: flex;
      justify-content: space-between;
      padding: 0 20rpx 40rpx;

      .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 164rpx;
        height: 208rpx;
        background-color: #f9f9f9;
        border-radius: 10rpx;

        .bottom-nav-title {
          display: flex;
          justify-content: center;
          margin-top: 37rpx;
          font-size: 24rpx;
          color: #1a191f;
        }

        .bottom-nav-img {
          margin-top: 40rpx;
          width: 135rpx;
        }

        .bottom-nav-gif {
          margin-top: 20rpx;
          width: 135rpx;
        }
      }
    }
  }
</style>
